package com.zheng.business.web.controller.task;

import com.zheng.business.common.constant.BusinessConstant;
import com.zheng.business.common.constant.BusinessResult;
import com.zheng.business.common.constant.BusinessResultConstant;
import com.zheng.business.web.service.BusinessMachineHttpTaskService;
import com.zheng.common.base.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @author lvg EMIAL：<a href="mailto:weiguo.liang@gh-ca.com">weiguo.liang@gh-ca.com</a> <br>
 * @version 1.0 <br>
 * @Company: GH-CA<br>
 * @ClassName: BusinessMachineHttpTaskController <br>
 * @Description: TODO <br>
 * @date 2019/8/8 11:54<br>
 **/
@RestController
@RequestMapping("/task/machine")
@Api(value = "设备金额统计任务控制器", description = "设备金额统计任务控制器")
public class BusinessMachineHttpTaskController  extends BaseController {

    @Autowired
    BusinessMachineHttpTaskService businessMachineHttpTaskService;
    /**
     * 每天凌晨 4点运行统计 统计前一天的设备金额
     * @param request
     * @return
     */
    @ApiOperation(value = "设备金额日统计任务")
    @RequestMapping(value = "/dayAmount", method = {RequestMethod.POST})
    public Object amount( HttpServletRequest request) {

        // request.getParameter("d"); //日期字符串 如： 2018-01-01
        return businessMachineHttpTaskService.statisticsMachineAmountByDateTypeAndDate(
                request.getParameter("d") , BusinessConstant.StatisticsDateType.DAY
        );
    }

    /**
     * 每月1号凌晨 4点运行统计
     * @param request
     * @return
     */
    @ApiOperation(value = "设备金额月统计任务")
    @RequestMapping(value = "/monthAmount", method = {RequestMethod.POST})
    public Object monthAmount( HttpServletRequest request) {
        // request.getParameter("d"); //日期字符串 如： 2018-01
        return businessMachineHttpTaskService.statisticsMachineAmountByDateTypeAndDate(
                request.getParameter("d") , BusinessConstant.StatisticsDateType.MONTH
        );
    }

    /**
     * 每年 1月1号 凌晨 4点运行统计
     * @param request
     * @return
     */
    @ApiOperation(value = "设备金额年统计任务")
    @RequestMapping(value = "/yearAmount", method = {RequestMethod.POST})
    public Object yearAmount( HttpServletRequest request) {
        // request.getParameter("d"); //日期字符串 如： 2018
        return businessMachineHttpTaskService.statisticsMachineAmountByDateTypeAndDate(
                request.getParameter("d") , BusinessConstant.StatisticsDateType.YEAR
        );
    }

    /**
     * 每天凌晨 4点运行统计 统计前一天的设备金额
     * @param request
     * @return
     */
    @ApiOperation(value = "设备日订单数统计任务")
    @RequestMapping(value = "/dayOrderCount", method = {RequestMethod.POST})
    public Object dayOrderCount( HttpServletRequest request) {

        // request.getParameter("d"); //日期字符串 如： 2018-01-01
        return businessMachineHttpTaskService.statisticsMachineOrderCountByDateTypeAndDate(
                request.getParameter("d") , BusinessConstant.StatisticsDateType.DAY
        );
    }

    /**
     * 每月1号凌晨 4点运行统计
     * @param request
     * @return
     */
    @ApiOperation(value = "设备月订单数统计任务")
    @RequestMapping(value = "/monthOrderCount", method = {RequestMethod.POST})
    public Object monthOrderCount( HttpServletRequest request) {
        // request.getParameter("d"); //日期字符串 如： 2018-01
        return businessMachineHttpTaskService.statisticsMachineOrderCountByDateTypeAndDate(
                request.getParameter("d") , BusinessConstant.StatisticsDateType.MONTH
        );
    }

    /**
     * 每年 1月1号 凌晨 4点运行统计
     * @param request
     * @return
     */
    @ApiOperation(value = "设备年订单数统计任务")
    @RequestMapping(value = "/yearOrderCount", method = {RequestMethod.POST})
    public Object yearOrderCount( HttpServletRequest request) {
        // request.getParameter("d"); //日期字符串 如： 2018
        return businessMachineHttpTaskService.statisticsMachineOrderCountByDateTypeAndDate(
                request.getParameter("d") , BusinessConstant.StatisticsDateType.YEAR
        );
    }
}
